
#import "ServerInfo.h"

@implementation ServerInfo

//
// name
//
@synthesize serverName														= _serverName;

//
// type
//
@synthesize serverType														= _serverType;

//
// address
//
@synthesize serverAddress													= _serverAddress;

//
// user name
//
@synthesize userName														= _userName;

//
// password
//
@synthesize password														= _password;

//
// init with config
//
- (id)initWithConfig:(NSDictionary*)serverConfig
{
	//
	// call super
	//
	self																	= [super init];
	if(!self)
		return nil;
	
	//
	// load
	//
	self.serverName															= [serverConfig valueForKey:@"serverName"];
	self.serverType															= [serverConfig valueForKey:@"serverType"];
	self.serverAddress														= [serverConfig valueForKey:@"serverAddress"];
	self.userName															= [serverConfig valueForKey:@"userName"];
	self.password															= [serverConfig valueForKey:@"password"];
	
	return self;
}

//
// dealloc
//
- (void)dealloc
{
	self.serverName															= nil;
	self.serverType															= nil;
	self.serverAddress														= nil;
	self.userName															= nil;
	self.password															= nil;
	
	[super dealloc];
}

//
// copy
//
- (id)copyWithZone:(NSZone*)zone
{
	ServerInfo* newCopy														= [[[self class] alloc] init];
	if(!newCopy)
		return nil;
	
	newCopy.serverName														= [[self.serverName copyWithZone:zone] autorelease];
	newCopy.serverType														= [[self.serverType copyWithZone:zone] autorelease];
	newCopy.serverAddress													= [[self.serverAddress copyWithZone:zone] autorelease];
	newCopy.userName														= [[self.userName copyWithZone:zone] autorelease];
	newCopy.password														= [[self.password copyWithZone:zone] autorelease];
	
	return newCopy;
}

//
// config dictionary
//
- (NSDictionary*)configDictionary
{
	NSMutableDictionary* config												= [NSMutableDictionary dictionaryWithCapacity:5];
	[config setValue:self.serverName forKey:@"serverName"];
	[config setValue:self.serverType forKey:@"serverType"];
	[config setValue:self.serverAddress forKey:@"serverAddress"];
	[config setValue:self.userName forKey:@"userName"];
	[config setValue:self.password forKey:@"password"];
	
	return config;
}

@end
